<?php

/**
 * Foire form.
 *
 * @package    SdCommerce
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class FoireForm extends BaseFoireForm {

    public function configure() {
        $this->widgetSchema->setLabels(array(
            'id_ville' => 'Ville', 'm_employe_list' => 'Liste des Employers'
        ));
        unset($this['created_at'], $this['updated_at']
        );
        $this->setWidget('date_debut', new sfWidgetFormInput());
        $this->setWidget('date_fin', new sfWidgetFormInput());
        $this->setWidget('libelle', new sfWidgetFormInput());
        $this->widgetSchema['libelle']->setAttribute("class", "required");
        $this->widgetSchema['date_debut']->setAttribute("class", "required");
        $this->widgetSchema['date_fin']->setAttribute("class", "required");
        $this->widgetSchema['id_ville']->setAttribute("class", "required");
         $this->widgetSchema['m_employe_list']->setAttribute("class", "required");
        
//        $employerfoires = EmployeFoire1Table::getInstance()->LoadAll();
        $employerfoires=EmployeFoire1Table::getInstance()->LoademplyerBydatefin();
        if (count($employerfoires) != 0) {
            $i = 0;
            $tab = array();
//            
            foreach ($employerfoires as $employerfoire) {

                $employerfoireId = $employerfoire->getIdEmployer();
                    $tab[$i] = $employerfoireId;
                    $i = $i + 1;
//               
            }
                $employernotfoire = sfGuardUserTable::getInstance()->LoadAllEmployerNotInEmployerFoire($tab);
                $this->widgetSchema['m_employe_list'] = new sfWidgetFormDoctrineChoice(array(
                            'multiple' => true,
                            'model' => 'sfGuardUser',
                            'query' => $employernotfoire,
                            'renderer_class' => 'sfWidgetFormSelectDoubleList'             ));
                
        } 
        if (count($employerfoires) == 0) {
            $Allemployer = sfGuardUserTable::getInstance()->findAllEmploye();
            $this->widgetSchema['m_employe_list'] = new sfWidgetFormDoctrineChoice(array(
                        'multiple' => true,
                        'model' => 'sfGuardUser',
                        'query' => $Allemployer,
                        'renderer_class' => 'sfWidgetFormSelectDoubleList'
                    ));
        }
    }

//        $this->widgetSchema['m_employe_list']->setOption('renderer_class', 'sfWidgetFormSelectDoubleList');
}

